import api from '../index'
import config from "@/config"
import tools from '@/tools'
// 用户ID
const userId = tools.localRead('userId')

export const goodsImport = (sku) => {
	const url = `${config.pre}/supplier-activity/goods/import?sku=${sku}&userId=${userId}`
	return api.get(url)
}

export const goodsListPush = (params) => {
	const url = `${config.pre}/supplier-activity/goods/list/push?userId=${userId}`;
	return api.get(url, params)
}

export const goodsPush = (params) => {
	const url = `${config.pre}/supplier-activity/workFlow/startWork?userId=${userId}`;
	return api.post(url, params)
}

export const goodsPushAll = (params) => {
	const url = `${config.pre}/supplier-activity/workFlow/startWork/list?userId=${userId}`;
	return api.post(url, params)
}

export const goodsInfo = (supplierId, sku) => {
	const url = `${config.pre}/supplier-activity/goods/goodsInfo?supplierId=${supplierId}&sku=${sku}`
	return api.get(url)
}

export const activityGoodsList = (goodsListId) => {
	const url = `${config.pre}/supplier-activity/workFlow/goods/List?goodsListId=${goodsListId}`;
	return api.get(url)
}

export const supplierUserList = (params) => {
	const url = `${config.pre}/supplier-activity/supplier/user/list?userId=${userId}`;
	return api.get(url, params)
}

export const supplierSearchUserList = (name) => {
	const url = `${config.pre}/supplier-activity/supplier/user/searchUser?name=${name}`;
	return api.get(url)
}

export const supplierUserBind = (params) => {
	const url = `${config.pre}/supplier-activity/supplier/user/bind?userId=${userId}`;
	return api.post(url, params)
}

export const supplierUserSave = (params) => {
	const url = `${config.pre}/supplier-activity/supplier/user/save?userId=${userId}`;
	return api.put(url, params)
}

export const getUserById = (id) => {
	const url = `${config.pre}/supplier-activity/supplier/user/user/${id}`;
	return api.get(url)
}

export const goodsListAll = (params) => {
	const url = `${config.pre}/supplier-activity/goods/list/all`
	return api.get(url, params)
}

// 初审商品驳回
// info：驳回原因
export const goodsFail = (supplierId, sku, info) => {
	// const url = `/vapi/supplier-activity/goods/fail/${sku}?supplierId=${supplierId}&info=${info}`
	const url = `${config.pre}/supplier-activity/goods/failv2/${sku}?supplierId=${supplierId}&info=${info}`
	return api.get(url)
}

export const goodsPrice = (supplierId, sku) => {
	const url = `${config.pre}/supplier-activity/goods/goodsPrice/${sku}?supplierId=${supplierId}`
	return api.get(url)
}

export const pushHistoryList = (id) => {
	const url = `${config.pre}/supplier-activity/goods/pushHistoryList/${id}`
	return api.get(url)
}

// 商品分类与项目经理绑定
export const categoryUserList = (params) => {
	const url = `${config.pre}/supplier-activity/category/user/list`;
	return api.get(url, params)
}

export const categorySearchUserList = (name) => {
	const url = `${config.pre}/supplier-activity/category/user/searchUser?name=${name}`;
	return api.get(url)
}

export const categoryUserBind = (params) => {
	const url = `${config.pre}/supplier-activity/category/user/bind`;
	return api.post(url, params)
}

export const categoryUserSave = (params) => {
	const url = `${config.pre}/supplier-activity/category/user/save`;
	return api.put(url, params)
}

export const getCategoryUserById = (id) => {
	const url = `${config.pre}/supplier-activity/category/user/user/${id}`;
	return api.get(url)
}

export const unbindCategoryUser = (id) => {
	const url = `${config.pre}/supplier-activity/category/user/unbind?id=${id}`;
	return api.delete(url)
}

export const categoryUser = () => {
	const url = `${config.pre}/supplier-activity/category/user/list?pageSize=100&pageNum=1`
	return api.get(url)
}

export const updateStock = (row) => {
	const url = `${config.pre}/supplier-activity/goods/updateStock`
	return api.post(url, row)
}

export const rejectInfo = (sku) => {
	const url = `${config.pre}/supplier-activity/goods/reject/${sku}`
	return api.get(url)
}

